//package com.rainsoftware.LicenseSystem.utils;
//
//import com.rainsoftware.LicenseSystem.utils.JsonServletRequestWrapper;
//import jakarta.servlet.Filter;
//import jakarta.servlet.FilterChain;
//import jakarta.servlet.FilterConfig;
//import jakarta.servlet.ServletException;
//import jakarta.servlet.ServletRequest;
//import jakarta.servlet.ServletResponse;
//import jakarta.servlet.http.HttpServletRequest;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//
//@Component
//public class HttpRequestFilter implements Filter {
//
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        // 可选的初始化逻辑
//    }
//
//    @Override
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        HttpServletRequest request = (HttpServletRequest) servletRequest;
//
//        if (request.getContentType() != null && request.getContentType().contains(MediaType.APPLICATION_JSON_VALUE)) {
//            // 处理 JSON 请求
//            ServletRequest requestWrapper = new JsonServletRequestWrapper(request);
//            filterChain.doFilter(requestWrapper, servletResponse);
//        } else {
//            filterChain.doFilter(servletRequest, servletResponse);
//        }
//    }
//
//    @Override
//    public void destroy() {
//        // 可选的销毁逻辑
//    }
//}
